<template>
  <div class="row">
    <div class="title">{{ title }}</div>
    <div class="content radio">
      <div class="tip">{{ tip }}</div>
      <div class="options">
        <label
          v-for="(item, index) in option"
          :key="index"
          :class="disabled ? 'disabled' : ''"
        >
          <input
            type="radio"
            :name="index"
            :value="index"
            :checked="value === item.value"
            :disabled="disabled"
            @click="onClick(item.value)"
          />
          {{ item.label }}
        </label>
        <!-- <van-radio-group
          v-model="value"
          direction="horizontal"
          @change="changeRadio"
        >
          <van-radio
            v-for="(item, index) in option"
            :key="index"
            :name="index"
            >{{ item }}</van-radio>
        </van-radio-group> -->
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'inputCardItem',
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    // 标题
    title: {
      type: String,
      default: ''
    },
    value: {
      type: [String, Number, Boolean],
      default: ''
    },
    // 提示
    tip: {
      type: String,
      default: ''
    },
    // radio options
    option: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {}
  },
  created() {},
  methods: {
    onClick(e) {
      console.log(this.disabled)
      if (this.disabled) return false
      this.$emit('input', e)
    }
  }
}
</script>

<style lang="scss" scoped>
.row {
  .title {
    font-family: PingFang SC Regular;
    font-size: 14px;
    font-weight: normal;
    line-height: 19px;
    letter-spacing: 0px;
    color: #171819;
  }

  .content {
    font-family: PingFang SC Regular;
    font-size: 16px;
    font-weight: normal;
    letter-spacing: 0px;
    color: #171819;
    position: relative;
    height: 38px;
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;

    input {
      width: 270px;
    }

    &::after {
      content: '';
      width: 100%;
      height: 0.5px;
      background: #e2e7ec;
      position: absolute;
      left: 0;
      bottom: 0;
    }

    .tip {
      font-family: PingFang SC Regular;
      font-size: 14px;
      font-weight: normal;
      line-height: 19px;
      letter-spacing: 0px;
      color: #b2b8bd;
    }
  }

  &:last-child {
    .content {
      margin-bottom: 0;

      &::after {
        display: none !important;
        height: 40px;
      }
    }
  }
}

// 单选框
.radio {
  height: auto !important;
  display: block !important;

  .tip {
    font-family: PingFang SC Regular;
    font-size: 12px;
    font-weight: normal;
    line-height: 16px;
    letter-spacing: 0px;
    color: #b2b8bd;
    margin-top: 6px;
  }
  .options {
    display: flex;
    font-size: 14px;
    line-height: 28px;
    height: 38px;
  }

  label {
    flex: 1;
    display: flex;
    align-items: center;
  }
  input[type='radio'] {
    border: 0.5px solid #e2e7ec;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
  }
  input[type='radio']:checked {
    border: 6px solid #2163e0;
  }
}
.disabled {
  input[type='radio']:checked {
    border: 6px solid #e2e7ec;
  }
  color: #b2b8bd !important;
}
</style>
